<?php
namespace app\admin\controller;
use app\admin\logic\AdminOperateLogic;

/**
 * 后台操作api控制器
 * Created by PhpStorm.
 * User: tyll
 * Date: 2019/11/21
 * Time: 09:38
 */
class AdminOperate extends Base {

    public function __construct(){
        parent::__construct();
        $this->ao_logic = new AdminOperateLogic();
    }

    /**
     * 获取后台操作
     * @return \think\response\Json
     */
    public function ajax_get_ao(){
        $params = input();
        $r = $this->check_admin_token($params);
        if($r['code'] != 1){
            return json($r);
        }

        $ao = new \app\common\controller\AdminOperate();

        $maps = $this->ao_logic->get_search_ao_maps();
        $limit =  ($params['page'] - 1) * $params['rows'];

        $list = model('admin_operate')->get_list($maps,'*','id desc','',$limit,$params['rows']);
        foreach($list as $k => $v){
            $r = $ao->deal_controller_action_desc($v['controller_action']);
            $list[$k]['controller_action_desc'] = $r['controller_action_desc'];
        }

        $total_num = model('admin_operate')->get_count($maps,'id');

        $data['list'] = $list;
        $data['total_num'] = $total_num;
        return json($this->ao_logic->get_response(1,'OK',$data));
    }
}